package com.chinasofti.lianxi;

import java.util.ArrayList;
import java.util.Scanner;

public class StudentTest {
    public static void main(String[] args) {
        ArrayList<Student> array = new ArrayList<>();
        //手动录入学生信息，存放到array
        addStudent(array);
        addStudent(array);
        addStudent(array);

        for (int i=0;i<array.size();i++){
            Student s = array.get(i);
            System.out.println(s.getAge()+"," + s.getName());
        }
    }

    public static void addStudent(ArrayList<Student> array){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入姓名：");
        String name = sc.nextLine();
        System.out.println("请输入年龄：");
        String age = sc.nextLine();

        Student s = new Student();
        s.setName(name);
        s.setAge(age);

        array.add(s);
    }

}